import 'package:animated_interpolation/smart_tabbar.dart';
import 'package:animated_interpolation/sweet_indicator_painter.dart';
import 'package:coinbaby/common/const/cosnt.dart';
import 'package:coinbaby/common/textstyle/textstyle.dart';
import 'package:coinbaby/page/autobuy/view/autobuy_cell.dart';
import 'package:coinbaby/page/autobuy/view/headType.dart';
import 'package:coinbaby/page/autobuy/view/select_tab.dart';
import 'package:coinbaby/page/home/view/bannerscroll.dart';
import 'package:flutter/material.dart';

class AutoBuy extends StatefulWidget {
  @override
  _AutoBuyState createState() => _AutoBuyState();
}

class _AutoBuyState extends State<AutoBuy> with SingleTickerProviderStateMixin {

  TabController _tabController;
  int currTabIndex = 0;
  static const List<String> titles = ["策略", "我的"];

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: Column(
          children: <Widget>[
            SelectTabView(
              currentIndex: currTabIndex,
              tabController: _tabController,
              titles: titles,
              onTap: (int index){
                setState(() {
                  currTabIndex = index;
                });
              },
            ),
            Expanded(
              child: Container(
                color: AppColor.grey,
                padding: const EdgeInsets.all(15),
                child: Column(
                  children: <Widget>[
                    SizedBox(
                      height: size.height * 0.1,
                      child: BannerView(),
                    ),
                    SizedBox(height: 15,),
                    HeadTypeView(),
                    Expanded(
                      child: ListView.builder(
                        itemCount: 2,
                        padding: const EdgeInsets.only(top: 15),
                        itemBuilder: (context, index) {
                          return InkWell(
                            onTap: () => Navigator.pushNamed(context, "/strategy"),
                            child: AutoBuyCell(index: index,)
                          );
                        } 
                      ),
                    )
                  ],
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}